import { Injectable } from '@nestjs/common';
import { CategoryDao as Dao } from '@/servers/daos/common/category/category.dao';

@Injectable()
export class CategoryService {
  constructor(private dao: Dao) {}

  /**
   * 通过type查询所有:组合查询条件
   */
  findAllByType(params: any): Promise<any> {
    const query = {
      where: {
        type: params.type,
        status: 0,
      },
      cache: {
        id: 'category_type_status',
        milisseconds: 25000,
      },
    };
    return this.dao.findAllByType(query);
  }
  
  /**
   * 查询所有
   */
  findAll(params: any): Promise<any> {
    return this.dao.findAll(params);
  }
  
  /**
   * 添加
   */
  add(params: any): Promise<any> {
    return this.dao.add(params);
  }

  /**
   * 修改
   * @param params
   */
  async update(params: any): Promise<any> {
    return this.dao.update(params);
  }

  /**
   * 删除
   * @param params
   */
  async delete(params: any): Promise<any> {
    return this.dao.delete(params);
  }
}
